package com.demo.travel.utils;

import android.content.Context;
import android.content.SharedPreferences;


public class SharedPreferencesUtils {

    public static final String PREFERENCE = "incon_sdk_pref";

    private SharedPreferences settings;

    private static SharedPreferencesUtils self = null;

    public SharedPreferencesUtils(Context context, String spf) {
        settings = context.getSharedPreferences(spf, Context.MODE_PRIVATE);
    }

    public static SharedPreferencesUtils getInstance(Context context) {
        if (self == null) {
            self = new SharedPreferencesUtils(context, PREFERENCE);
        }
        return self;
    }

    public void putBoolean(String paramString, boolean paramBoolean) {
        settings.edit().putBoolean(paramString, paramBoolean).commit();
    }

    public boolean getBoolean(String paramString, boolean defaultValue) {
        return settings.getBoolean(paramString, defaultValue);
    }

    public void putString(String paramString, String paramValue) {
        settings.edit().putString(paramString, paramValue).commit();
    }

    public String getString(String paramString) {
        return settings.getString(paramString, "");
    }

    public void putInt(String paramString, int paramValue) {
        settings.edit().putInt(paramString, paramValue).commit();
    }

    public int getInt(String paramString, int defaultValue) {
        int temp = 0;
        try {
            temp = settings.getInt(paramString, defaultValue);
        } catch (Exception e) {
            System.out.println(e);
        }
        return temp;
    }

    public void putLong(String paramString, long paramValue) {
        settings.edit().putLong(paramString, paramValue).commit();
    }

    public long getLong(String paramString, long defaultValue) {
        return settings.getLong(paramString, defaultValue);
    }

    public void deleteStr(String paramString) {
        settings.edit().remove(paramString).commit();
    }

    public void clearData() {
        settings.edit().clear().apply();
    }
}